package com.thuan.hibernate;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * Simple demo that uses java.util.Timer to schedule a task to execute once 5
 * seconds have passed.
 */

public class TimerTester {

  Timer timer;
  
  public TimerTester() {
    timer = new Timer();
    //timer.schedule(new RemindTask(), repeaterSeconds * 1000);
    timer.scheduleAtFixedRate(new RemindTask(), 0 * 1000, 6 * 1000);
  }
	
  class RemindTask extends TimerTask {
    public void run() {
      System.out.println("Time's up! " + new Date());
      timer.cancel(); //Not necessary because we call System.exit
      //System.exit(0); //Stops the AWT thread (and everything else)
    }
  }

  public static void main(String args[]) {
    System.out.println("About to schedule task.");
    new TimerTester();
    System.out.println("Task scheduled.");	
  }
}